package model

import "time"

// OperationLog 操作日志模型
type OperationLog struct {
	ID         uint      `gorm:"primaryKey" json:"id"`
	UserID     uint      `gorm:"type:int;comment:用户ID" json:"userId"`
	Username   string    `gorm:"type:varchar(50);comment:用户名" json:"username"`
	Module     string    `gorm:"type:varchar(50);comment:操作模块" json:"module"`
	Operation  string    `gorm:"type:varchar(50);comment:操作类型" json:"operation"`
	Method     string    `gorm:"type:varchar(10);comment:请求方法" json:"method"`
	Path       string    `gorm:"type:varchar(200);comment:请求路径" json:"path"`
	IP         string    `gorm:"type:varchar(50);comment:IP地址" json:"ip"`
	Location   string    `gorm:"type:varchar(100);comment:IP归属地" json:"location"`
	Status     int       `gorm:"type:int;comment:状态码" json:"status"`
	Message    string    `gorm:"type:varchar(500);comment:响应消息" json:"message"`
	RequestAt  time.Time `gorm:"comment:请求时间" json:"requestAt"`
	ResponseAt time.Time `gorm:"comment:响应时间" json:"responseAt"`
	Duration   int64     `gorm:"type:bigint;comment:耗时(ms)" json:"duration"`
	CreatedAt  time.Time `json:"createdAt"`
}

// TableName 指定表名
func (OperationLog) TableName() string {
	return "operation_logs"
}
